/*
 * Copyright (c) 2006-2021, Ulandlink Development Team
 *
 * SPDX-License-Identifier: Apache-2.0
 *
 * Change Logs:
 * Date           Author       Notes
 * 2022-12-29     xpw          first version
 * 2023-02-20     xpw          sync
 */
 
#ifndef __HTTP_PUB_H__
#define __HTTP_PUB_H__

#include <rtthread.h>
#include <at_socket.h>

#if HTTP_SERVER_ENABLE

#define WEB_ROOT "/web"
#define WEB_DEFAULT_FILE        WEB_ROOT"/index.html.gz"

#define HTTP_CACHE_CONTROL      600  //10mins

#define WEB_USERNAME_LEN        32
#define WEB_PASSWORD_LEN        32
#define WEB_SYS_FW_PKG_DIR      "/"

#define HTTP_SERVER_NAME        "Charger_web"

/* optional function */
//#define ETH_DHCP_SWITCH_ENABLE
/* end of optional function */

#define WEB_FACTORY_UPLOAD_HTML \
        "<!DOCTYPE html><html><head><script type=\"text/javascript\" languge=\"javascript\">"\
        "document.addEventListener(\"DOMContentLoaded\", function()"\
        "{document.body.style.display = \"block\";});"\
        "function file_selected(){var file = document.getElementById(\"file\").files[0];}"\
        "function upload_confirm(form){var file = document.getElementById(\"file\").files[0];if(file){"\
        "var ele = document.getElementById(\"upload_slct\");var index = ele.selectedIndex;"\
        "var ret = confirm(\"Are you sure to upload web firmware?\");if(ret)form.submit();}"\
        "else{alert(\"You must select a file\");}}</script></head><body>"\
        "<iframe id=\"nm_iframe\" name=\"nm_iframe\" style=\"display:none\" onload=\"get_result()\"></iframe>"\
        "<div id=\"content\"><div style=\"display: flex;margin-bottom: 13px;\"><div><div><div>"\
        "<form method=\"POST\" enctype=\"multipart/form-data\" action=\"/upload\"><div>"\
        "<select name=\"upload_slct\" id=\"upload_slct\"><option value =\"Opt101\">Update Web Firmware</option>"\
        "</select>&nbsp;&nbsp;"\
        "<input type=\"button\" name=\"upload_btn\" id=\"upload_btn\" value=\"Start Upload\" onclick=\""\
        "upload_confirm(form)\"/></div><br/>"\
        "<input type=\"file\" name=\"file\" id=\"file\" value=\"browse\" onchange=\"file_selected()\"/>"

#endif
#endif
